﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/AdminTemplate.Master" AutoEventWireup="true"
    CodeBehind="ManageAccounts.aspx.cs" Inherits="RealtorsPortal.AdminCP.ManageAccounts" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Accounts Management</title>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            //set option
            $("#navheadAdmin").addClass("selected");
            $("#mnuAdmin").css("display", "block");
            $(".submenu li a[title='Manage accounts']").css({ "color": "#fff", "background": "#222", "border": "1px solid #333" });

            $("#contentArea").tabs(); //tab view
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>
        ACCOUNTS MANAGEMENT</h1>
    <div id="contentArea">
        <ul>
            <li><a href="#tab1">Accounts list</a></li>
            <li><a href="#tab2">Add new account</a></li>
        </ul>
        <div id="tab1">
            <fieldset>
                Filter:<asp:DropDownList 
                    ID="ddlRolesFilter" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="ddlRolesFilter_SelectedIndexChanged">
                </asp:DropDownList>
                <div style="float:right;">
                Search: 
                <asp:TextBox ID="txtKeyword" runat="server" ValidationGroup="search"></asp:TextBox>
                <asp:Button ID="btnSearch" runat="server" Text="Search by username" 
                        CssClass="submit" ValidationGroup="search" style="float:none;" 
                        onclick="btnSearch_Click" />
                </div>
            </fieldset>

            <asp:GridView ID="grvAccounts" runat="server" AutoGenerateColumns="False" 
                DataKeyNames="UserId" AllowPaging="True" PageSize="5" 
                onpageindexchanging="grvAccounts_PageIndexChanging" 
                onrowdeleting="grvAccounts_RowDeleting" 
                onrowediting="grvAccounts_RowEditing" Width="100%">
                <HeaderStyle CssClass="header_gridview" />
                <AlternatingRowStyle CssClass="alt"/>
                <Columns>
                    <asp:CheckBoxField />
                    <asp:TemplateField HeaderText="ID">
                        <ItemTemplate>
                            <%# Eval("UserId")%>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Username">
                        <ItemTemplate>
                            <%# Eval("Username")%>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Fullname">
                        <ItemTemplate>
                            <%# Eval("FirstName")%>
                            <%# Eval("LastName")%>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Email">
                        <ItemTemplate>
                            <%# Eval("Email")%>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Company">
                        <ItemTemplate>
                            <%# Eval("Company")%>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Reg Date">
                        <ItemTemplate>
                            <%# Eval("RegDate")%>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Active">
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Eval("IsActive")%>' Enabled="False" />
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Actions">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" CausesValidation="False" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>
                                <img src="assets/b_edit.png" alt="Edit" title="Edit" />
                            </asp:LinkButton>
                            <asp:LinkButton ID="LinkButton4" runat="server" Text="Delete" CausesValidation="False" CommandName="Delete" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' OnClientClick='javascript:return confirm("Are you sure you want to delete?")'>
                                <img src="assets/b_drop.png" alt="Delete" title="Delete">
                            </asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <PagerStyle CssClass="pager_gridview" Width="50px" />
            </asp:GridView>
            <asp:Label ID="Label1" runat="server" Text="Display: "></asp:Label><asp:DropDownList
                ID="ddlPageSize" runat="server" AutoPostBack="True" 
                onselectedindexchanged="ddlPageSize_SelectedIndexChanged">
                <asp:ListItem>5</asp:ListItem>
                <asp:ListItem>10</asp:ListItem>
                <asp:ListItem>20</asp:ListItem>
            </asp:DropDownList>

            <asp:Panel ID="AccountEditPanel" runat="server" Visible="False">
                ________________________________________________________________________________________________________________________
                <h2>
                    AccountID : 
                    <asp:Label ID="lblAccountId" runat="server" ForeColor="#33CC33"></asp:Label> 
                    &nbsp;&nbsp;Register date: 
                    <asp:Label ID="lblRegDate" runat="server" ForeColor="#33CC33"></asp:Label>
                    &nbsp;&nbsp;Type: 
                    <asp:Label ID="lblRole" runat="server" ForeColor="#33CC33"></asp:Label>
                </h2>
                <fieldset>
                    <legend>Edit account</legend>
                    
                <div class="input_field">
                    <label>
                        Username(*):
                    </label>
                    <asp:TextBox ID="txtUserName" runat="server" Width="215px">
                    </asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtUsername"
                        ErrorMessage="Username is required!" Font-Bold="True" ForeColor="Red" 
                        ValidationGroup="edit"></asp:RequiredFieldValidator>
                </div>
                <div class="input_field">
                    <label>
                        Email:
                    </label>
                    <asp:TextBox ID="txtEmail" runat="server" Width="215px">
                    </asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                        ErrorMessage="Email is required!" Font-Bold="True" ForeColor="Red" ControlToValidate="txtEmail"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" 
                        ControlToValidate="txtEmail" ValidationGroup="edit" runat="server" 
                        ErrorMessage="Email is invalid" Font-Bold="True" ForeColor="Red" 
                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                </div>
                <div class="input_field">
                    <label>
                        First name:
                    </label>
                    <asp:TextBox ID="txtFirstName" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Last name:
                    </label>
                    <asp:TextBox ID="txtLastName" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Address:
                    </label>
                    <asp:TextBox ID="txtAddress" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Phone:
                    </label>
                    <asp:TextBox ID="txtPhone" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Company:
                    </label>
                    <asp:TextBox ID="txtCompany" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Paypal Account:
                    </label>
                    <asp:TextBox ID="txtPaypalAccount" runat="server" Width="215px">
                    </asp:TextBox>
                </div>

                <div class="input_field">
                    <label>
                        Active:
                    </label>
                    <asp:CheckBox ID="chkIsActive" runat="server" />
                </div>

                <div class="input_field no_margin_bottom">
                    <label>
                        &nbsp;</label>
                    <asp:Button ID="btnEdit" runat="server" Text="Edit" CssClass="submit" ValidationGroup="edit" 
                        onclick="btnEdit_Click"/>
                    <input class="submit" type="reset" value="RESET" />
                </div>

                </fieldset>

            </asp:Panel>
        </div>
        <div id="tab2">
            <fieldset>
                <legend>Add new account</legend>
                <div class="input_field">
                    <label>
                        Become a:
                    </label>
                    <asp:DropDownList ID="ddlRoles" runat="server" Width="230px">
                    </asp:DropDownList>
                </div>
                <div class="input_field">
                    <label>
                        Username(*):
                    </label>
                    <asp:TextBox ID="atxtUsername" runat="server" Width="215px">
                    </asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="atxtUsername"
                        ErrorMessage="Username is required" Font-Bold="True" ForeColor="Red"></asp:RequiredFieldValidator>
                </div>
                <div class="input_field">
                    <label>
                        Password(*):
                    </label>
                    <asp:TextBox ID="atxtPassword" runat="server" Width="215px" TextMode="Password">
                    </asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                        ControlToValidate="atxtPassword" ErrorMessage="Password is required" 
                        Font-Bold="True" ForeColor="Red"></asp:RequiredFieldValidator>
                </div>
                <div class="input_field">
                    <label>
                        Confirm(*):
                    </label>
                    <asp:TextBox ID="atxtConfirm" runat="server" Width="215px" TextMode="Password">
                    </asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                        ControlToValidate="atxtConfirm" ErrorMessage="Confirm is required" 
                        Font-Bold="True" ForeColor="Red"></asp:RequiredFieldValidator>
                    <asp:CompareValidator ID="CompareValidator1" runat="server" 
                        ControlToCompare="atxtPassword" ControlToValidate="atxtConfirm" 
                        ErrorMessage="Password does not matches!" Font-Bold="True" ForeColor="Red"></asp:CompareValidator>
                </div>
                <div class="input_field">
                    <label>
                        Email(*):
                    </label>
                    <asp:TextBox ID="atxtEmail" runat="server" Width="215px">
                    </asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                        ControlToValidate="atxtEmail" ErrorMessage="Email is required" Font-Bold="True" 
                        ForeColor="Red"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                        ControlToValidate="atxtEmail" ErrorMessage="Email is invalid" Font-Bold="True" 
                        ForeColor="Red" 
                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                </div>
                <div class="input_field">
                    <label>
                        First name:
                    </label>
                    <asp:TextBox ID="atxtFirstName" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Last name:
                    </label>
                    <asp:TextBox ID="atxtLastName" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Address:
                    </label>
                    <asp:TextBox ID="atxtAddress" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Phone:
                    </label>
                    <asp:TextBox ID="atxtPhone" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Company:
                    </label>
                    <asp:TextBox ID="atxtCompany" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field">
                    <label>
                        Paypal Account:
                    </label>
                    <asp:TextBox ID="atxtPaypal" runat="server" Width="215px">
                    </asp:TextBox>
                </div>
                <div class="input_field no_margin_bottom">
                    <label>
                        &nbsp;</label>
                    <asp:Button ID="btnAdd" runat="server" Text="ADD" CssClass="submit" 
                        onclick="btnAdd_Click" />
                    <input class="submit" type="reset" value="RESET" />
                </div>
            </fieldset>
        </div>
    </div>
</asp:Content>
